AutoHotkey/Radar zoom (enhanced)
This piece of AHK script extends the radar zoom in/out hotkeys (previously + and -) to also keep track of the knot-seconds per grid scale for the current radar display. In an effort to make this universally portable nothing is hard coded but of course it very easily could be hard coded to streamline or indeed eliminate some of the setup and calibration steps. (see table at end of article) Motivation The motivation for this tool is described at the article Pre-start#Calibrate radar grid units and is summarized in the comments in the first 5 lines of the script. The display of knot-seconds per grid unit is done with a tooltip GUI. It is crude but effective. It's major drawback is that the display cannot remain on top when VSK is played in full screen mode. If you have a two monitor setup or play VSK in windowed mode then you could easily adapt the script to have this number displayed in a separate window that updates on each press of the hotkeys for zoom in and zoom out. An expedient workaround was to use RAlt+F11 to briefly display the current zoom level without changing the radar zoom. With the knot-second per grid constant displayed (say 225) then you use mental arithmetic to divide that value by the current SOG (in knots) to determine the time to traverse one grid unit at the current SOG. * So if SOG is 12.5kts then you can expect to take 18 seconds to traverse one grid unit on the radar. * If your SOG is 15kts then 15 seconds * ... and so on and so forth. This tool is not recommended for the arithmetically challenged! Script ; radar zoom hotkeys are F11 and F12 (but could just as easily be the - and + keys) ; make sure these keys are not bound to in-game functions and do not get used in chat messages ; a. If game window gets resized then erase old coords by pressing F11 and F12 at the same time ; b. Calibrate knot-seconds per radar grid unit by pressing RAlt+F12 ; c. Display current knot-seconds per grid unit by pressing RAlt+F11 ; gZoom=0 ; the product of time to traverse one grid unit (in seconds) and SOG (in Knots) gScale=1.5 ; the scale factor for each press of zoom in/out on radar display (not used - hard coding was necessary) SetFormat, float, 0.6 ; 6 decimal place precision for floating point numbers F12:: ; radar zoom in (+) takes effect on key release If RadarPlusX { KeyWait F12 gZoom /=1.5 ; 6 decimal place precision ensures insignificant rounding errors SendEvent {Click, %RadarPlusX%, %RadarPlusY%} ;uses mouse speed from SetDefaultMouseSpeed SetFormat, float, 0.0 ; no decimal place makes mental arithmetic simpler gDisp:= gZoom * 1.0 ; note that gZoom always has 6 decimal place precision SetFormat, float, 0.6 Loop 100 Tooltip,%gDisp%,RadarPlusX-40,RadarPlusY-40 ToolTip }else{ MouseGetPos, RadarPlusX, RadarPlusY MsgBox,0,Mouse Coordinates ,Assigned`nX: %RadarPlusX%`nY:%RadarPlusY%`nRestoring window ... ,2 ; decrease this timeout delay to 0.1 once familiar with process WinRestore ahk_class GbxApp } return F11:: ; radar zoom out (-) takes effect on key release If RadarMinusX { KeyWait F11 gZoom *=1.5 SendEvent {Click, %RadarMinusX%, %RadarMinusY%} ;uses mouse speed from SetDefaultMouseSpeed SetFormat, float, 0.0 gDisp:= gZoom * 1.0 SetFormat, float, 0.6 Loop 100 Tooltip,%gDisp%,RadarMinusX-40,RadarMinusY-40 ToolTip }else{ MouseGetPos, RadarMinusX, RadarMinusY MsgBox,0,Mouse Coordinates ,Assigned`nX: %RadarMinusX%`nY:%RadarMinusY%`nRestoring window ... ,2 ; decrease this timeout delay to 0.1 once familiar with process WinRestore ahk_class GbxApp } return F11 & F12:: ; erase X,Y coords for radar zoom buttons (press - and = at the same time and then release) RadarPlusX := "" RadarPlusY := "" RadarMinusX := "" RadarMinusY := "" MsgBox,0,Mouse Coordinates, ( Erased X`,Y coords for radar buttons Position mouse cursor over button and press either F11(-) or F12(+) key Click OK to restore game window. ) WinRestore ahk_class GbxApp return RAlt & F12:: ; calibrate radar grid ; User enters time to travel one square of the radar grid (seconds) and current SOG (Knots) ; script calculates the numerator (knot-seconds) to use with any future SOG (as denominator) to ; quickly figure out (by mental arithmetic) seconds to traverse one grid unit on the radar. ; KeyWait Alt KeyWait F11 KeyWait F12 sTitle:="Calibrate RADAR" sPrompt:="Enter seconds to traverse one grid square and SOG in knots" sDefault:="time(seconds) , SOG(knots)" InputBox,sInput,%sTitle%,%sPrompt%,,,,,,,, %sDefault% ;Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default StringSplit,aParam,sInput,`,,%A_Tab%%A_Space% SetFormat, float, 0.6 gZoom:= aParam1 * aParam2 SetFormat, float, 0.0 gDisp:= gZoom * 1.0 SetFormat, float, 0.6 MsgBox,0,Kt-sec (per grid square) %sInput% ,%aParam1% * %aParam2% = %gDisp% ,2 ; decrease this timeout delay to 0.1 once familiar with process WinRestore ahk_class GbxApp return RAlt & F11:: ; display tooltip with knot-seconds product for the current radar zoom If gZoom { KeyWait F11 KeyWait RAlt SetFormat, float, 0.0 gDisp:= gZoom * 1.0 SetFormat, float, 0.6 }else{ gDisp:="not defined" } Loop 100 Tooltip,%gDisp%,RadarMinusX-40,RadarMinusY-40 ToolTip return Room for improvement Since the unit for knot-seconds is distance (1 knot-second = 1/3600 Nm) it should be the case that for any given grid square dimension the knot-second scale is a constant at each zoom level and that any variations from this constant is due to small errors a user makes when determining the time to traverse one grid unit (in seconds) or the average SOG (in knots). Perhaps if enough data points are sampled a precise table of constants can be prepared. This was done for the ACC boat model on a Marseilles map for 3 sets of concentric rings on the radar display and 10 zoom levels. The DNM (in Nm) as displayed in the instrument cluster was noted as the radar blip for a distant course marker touched each of 3 concentric rings. Without showing the raw data or statistical analysis the following table summarizes those constants. If someone is prepared to take a greater sample size then please feel free to improve upon (or uphold) the accuracy of this table. It would be especially helpful to know if this is unchanging from one boat model to the next and from one sailing venue to the next. #If these numbers can be independently verified then it might make sense to have the script use the entered values for SOG and time at one zoom setting to estimate which of 10 constants to use and then round up or down to that constant. #Note that the scaling by 1.5 on each press of the zoom in/out hotkey is taken care of by the script. It turns out that the empirical data suggests that this scale factor is 1.53 and not 1.50 so if another person can independently verify to decimal place precision then that might improve this tool a little more. #Of course if anyone can describe how to make an AHK generated tooltip persist on top of the full screen VSK game view then that would be a huge improvement! #I noticed that the code, gZoom *=1.5 could not be parameter-ised using gZoom *=%gScale%. If an experienced AHK programmer can help in that regard it would be nice. I suppose that gZoom = %gZoom% * %gScale% is always a fall back option! Category:Glossary